package com.cssw.fyzb.web.service;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.core.dao.acct.AcctExtDao;
import com.cssw.fyzb.core.dao.exchange.GExchangeFDefDao;
import com.cssw.fyzb.core.dao.exchange.YExchangeFDefDao;
import com.cssw.fyzb.core.model.dodb.GExchangeFDef;
import com.cssw.fyzb.core.model.dodb.RnbExchangeFDef;
import com.cssw.fyzb.core.model.dodb.YExchangeFDef;
import com.ydn.dbframe.plugin.activerecord.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Service
public class ExchangeDefService {
    @Autowired
    private YExchangeFDefDao yExchangeFDefDao;
    @Autowired
    private GExchangeFDefDao gExchangeFDefDao;
    @Autowired
    private AcctExtDao acctExtDao;

    public AjaxPage<YExchangeFDef> yList(int page, int limit, Map param) {
        Page<YExchangeFDef> list = yExchangeFDefDao.getAllDef(param,page, limit);
        return AjaxPage.success(list.getList(),list.getTotalRow(),list.getTotalPage());
    }
    public Boolean yDelete(Long yfId, Long userID) {
      yExchangeFDefDao.delete(yfId,userID);
      return true;
    }

    public Boolean yUpdate(Long yfId, BigDecimal yCoin,BigDecimal fCoin,Long userId) {
        yExchangeFDefDao.update(yfId,yCoin,fCoin,userId);
        return true;
    }

    public Boolean yAdd(BigDecimal yCoin,BigDecimal fCoin,Long userId) {
        yExchangeFDefDao.add(yCoin,fCoin,userId);
        return true;
    }

    public AjaxPage<GExchangeFDef> gList(int page, int limit, Map param) {
        Page<GExchangeFDef> list = gExchangeFDefDao.getAllDef(param,page, limit);
        return AjaxPage.success(list.getList(),list.getTotalRow(),list.getTotalPage());
    }

    public Boolean gDelete(Long yfId, Long userID) {
        gExchangeFDefDao.delete(yfId,userID);
        return true;
    }

    public Boolean gUpdate(Long yfId, BigDecimal gCoin,BigDecimal fCoin,Long userId) {
        gExchangeFDefDao.update(yfId,gCoin,fCoin,userId);
        return true;
    }

    public Boolean gAdd(BigDecimal gCoin,BigDecimal fCoin,Long userId) {
        gExchangeFDefDao.add(gCoin,fCoin,userId);
        return true;
    }




    public AjaxPage<RnbExchangeFDef> rnbList(int page, int limit, Map param) {
        Page<RnbExchangeFDef> list = acctExtDao.getAllDef(param,page, limit);
        return AjaxPage.success(list.getList(),list.getTotalRow(),list.getTotalPage());
    }
    public Boolean rnbDelete(Long rfId, Long userID) {
        acctExtDao.delete(rfId,userID);
        return true;
    }

    public Boolean rnbUpdate(Long rfId, BigDecimal rnb,BigDecimal fCoin,Long userId) {
        acctExtDao.update(rfId,rnb,fCoin,userId);
        return true;
    }

    public Boolean rnbAdd(BigDecimal rnb,BigDecimal fCoin,Long userId) {
        acctExtDao.add(rnb,fCoin,userId);
        return true;
    }
}
